<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    * {
        padding: 0;
        margin: 0;
    }

    input {
        width: 85%;
        height: 30px;
        border-radius: 10px;
        margin-right: 10px;
        margin-bottom: 10px;
    }

    .list {
        width: 100%;
        height: 30px;
        background-color: rgb(115, 224, 231);
        border-radius: 10px;
        text-align: center;
        line-height: 30px;
        margin-bottom: 10px;
        margin-right: 5px;
    }
    .let{
        display: flex;
        flex-wrap: wrap;
    }
</style>

<body>
    <div id="arr">
        <div class="box">
            <div class="get">
                <input type="text" placeholder="搜索" v-model="inputText">
                 <span @click="add">搜索</span>
            </div>
            <p>历史搜索</p>
            <div class="let" v-for="(item,index) in tasklist" :key="index"> 
                <div class="left">
                    <div class="list">{{item.name}}</div>
                </div>

            </div>
        </div>


    </div>
</body>

</html>
<script src="./vue-2.5.21.js"></script>
<script>
    var V = new Vue({
        el: '#arr',
        data: {
            inputText: '',
            tasklist: []

        },
        methods: {
            add() {
                if (this.inputText) {
                    var obj = { id: this.tasklist.length + 1, name: this.inputText }
                    this.tasklist.push(obj)
                    this.inputText = ''
                }

            }
        }
    })
</script>